Skip to content

[model] optimize padding mask reduction memory - #167

Merged
hjh0119 merged 1 commit into
modelscope:mainfrom
Zhijun-Xu:perf/optimize-padding-mask-reduction
Aug 24, 2026
Merged

[model] optimize padding mask reduction memory#167
hjh0119 merged 1 commit into
modelscope:mainfrom
Zhijun-Xu:perf/optimize-padding-mask-reduction

Conversation

@Zhijun-Xu

Copy link
Copy Markdown
Contributor

For a 128K sequence length, calling .sum() on the boolean attention mask promotes it to int64, resulting in a temporary tensor exceeding 90 GB.
Replace it with the logically equivalent Tensor.all() operation, which performs a native boolean reduction and avoids the large temporary allocation.

@hjh0119
hjh0119 merged commit 3197f74 into modelscope:main Aug 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants